package cn.edu.wfit.modules.directionmanagement.controller;

import java.util.List;

import cn.edu.wfit.modules.directionmanagement.domain.WfitRecordtime;
import cn.edu.wfit.modules.directionmanagement.service.IWfitRecordtimeService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.edu.wfit.common.log.annotation.Log;
import cn.edu.wfit.common.log.enums.BusinessType;
import cn.edu.wfit.common.security.annotation.RequiresPermissions;

import cn.edu.wfit.common.core.web.controller.BaseController;
import cn.edu.wfit.common.core.web.domain.AjaxResult;
import cn.edu.wfit.common.core.utils.poi.ExcelUtil;
import cn.edu.wfit.common.core.web.page.TableDataInfo;

/**
 * 记录学习时间Controller
 * 
 * @author ruoyi
 * @date 2025-09-09
 */
@RestController
@RequestMapping("/recordTime")
public class WfitRecordtimeController extends BaseController
{
    @Autowired
    private IWfitRecordtimeService wfitRecordtimeService;

    /**
     * 查询记录学习时间列表
     */
    @RequiresPermissions("system:recordTime:list")
    @GetMapping("/list")
    public TableDataInfo list(WfitRecordtime wfitRecordtime)
    {
        startPage();
        List<WfitRecordtime> list = wfitRecordtimeService.selectWfitRecordtimeList(wfitRecordtime);
        return getDataTable(list);
    }

    /**
     * 导出记录学习时间列表
     */
    @RequiresPermissions("system:recordTime:export")
    @Log(title = "记录学习时间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfitRecordtime wfitRecordtime)
    {
        List<WfitRecordtime> list = wfitRecordtimeService.selectWfitRecordtimeList(wfitRecordtime);
        ExcelUtil<WfitRecordtime> util = new ExcelUtil<WfitRecordtime>(WfitRecordtime.class);
        util.exportExcel(response, list, "记录学习时间数据");
    }

    /**
     * 获取记录学习时间详细信息
     */
    @RequiresPermissions("system:recordTime:query")
    @GetMapping(value = "/{timeId}")
    public AjaxResult getInfo(@PathVariable("timeId") Long timeId)
    {
        return success(wfitRecordtimeService.selectWfitRecordtimeByTimeId(timeId));
    }

    /**
     * 新增记录学习时间
     */
    @Log(title = "记录学习时间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfitRecordtime wfitRecordtime)
    {
        return toAjax(wfitRecordtimeService.insertWfitRecordtime(wfitRecordtime));
    }

    /**
     * 修改记录学习时间
     */
    @RequiresPermissions("system:recordTime:edit")
    @Log(title = "记录学习时间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfitRecordtime wfitRecordtime)
    {
        return toAjax(wfitRecordtimeService.updateWfitRecordtime(wfitRecordtime));
    }

    /**
     * 删除记录学习时间
     */
    @RequiresPermissions("system:recordTime:remove")
    @Log(title = "记录学习时间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{timeIds}")
    public AjaxResult remove(@PathVariable Long[] timeIds)
    {
        return toAjax(wfitRecordtimeService.deleteWfitRecordtimeByTimeIds(timeIds));
    }
}
